import { message } from "antd";
import axios from "axios";
export default function myAxios(url, data = {}, type = "GET") {
  return new Promise((resovle, _) => {
    let promise;
    if (type === "GET") {
      promise = axios.get(url, { params: { ...data } });
    } else {
      promise = axios.post(url, { ...data });
    }
    promise
      .then((res) => {
        resovle(res.data);
      })
      .catch((err) => {
        message.error(err.message);
      });
  });
}
